package kr.co.hpc.partner.controller;

import kr.co.hpc.partner.form.Contact;
import kr.co.hpc.partner.vo.UserVo;
import kr.co.hpc.partner.controller.LoginController;

import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;

@Controller
@SessionAttributes
public class ContactController {

	@RequestMapping(value = "/addContact", method = RequestMethod.POST)
	public String addContact(@ModelAttribute("contact")
							Contact contact, BindingResult result) {
		
		System.out.println("First Name:" + contact.getFirstname() + 
					"Last Name:" + contact.getLastname());
		
		
		return "redirect:contacts.html";
	}

//	@RequestMapping(value = "/submitLogin", method = RequestMethod.POST)
//	public String submitLogin(@ModelAttribute("login")
//	UserVo userVo, BindingResult result) {
//		
//		System.out.println("getUserId = " + userVo.getUserId() + 
//				"  getUserPw = " + userVo.getUserPw());
//		
//		LoginController lg = new LoginController();
//		UserVo dd = lg.selectUser(userVo);
//		
//		System.out.println("result = " + dd.getUserId());
//		
//		return "redirect:login.html";
//	}
	
	
	
	@RequestMapping("/contacts")
	public ModelAndView showContacts() {
		
		return new ModelAndView("contact", "command", new Contact());
	}

	@RequestMapping("/start")
	public ModelAndView showStart() {
		
//		return new ModelAndView("start", "command", new Contact());
		return new ModelAndView("start");
	}
	
	@RequestMapping("/login")
	public ModelAndView showLogin() {
		
		System.out.println("login!!!!!!!!!!!!!!!!!!!!!!!");
		
		LoginController lg = new LoginController();
//		lg.selectUser(userVo);
//		return new ModelAndView("start", "command", new Contact());
		
//		UserVo vo = new UserVo();
//		Login lg = new Login();
//		lg.selectUser(vo);
		
		
		return new ModelAndView("login");
	}
	
	
}
